const db = uniCloud.database();
module.exports = async function(options = {}) {
	let { list, uid } = options;
	const token = this.getUniIdToken();
	if (!token || !uid || !list) {
		throw new Error('非法操作');
	}
	const promises = list.map((item, index) => {
		let courseOrder = index + 1;
		return db.collection('a-dz-course-list-custom')
			.where({
				uid,
				courseId: +item.courseId
			})
			.update({
				courseOrder,
				courseGroup: item.courseGroup,
				courseGroupName: item.courseGroupName
			})
	})
	await Promise.all(promises);
	return {
		code: 0,
		msg: '修改成功'
	}
}